<?php
require_once("init.php");
$g=$_POST['g'];
if(empty($g)) {?>
<form method="POST" action="g.php">
    <input type="text" name="g" />
    <input type="submit" value="go" />
</form>
    <?php
} else {
    header("Location: b.php?g=".my_url_encode($g));
}
?>